import { get, post, put } from "../utils/request";
import { removePropertyOfNull } from "../utils/utils";

//根据设备sn获取状态
export const getEquipSn = (params) => {
  return get("/cloud-equip/equip-info/get/agent/incoming", {
    ...params,
  });
};

// 获取店铺详情
export const getStoreDetail = (id) => {
  return get("/cloud-merchant/mrc/store/detail", {
    id,
  });
};
//员工结算信息
export const accountUpdate = (state, data, storeMenId) => {
  const { merchant, settlement } = state;
  data.attachList = [
    {
      filePath: merchant.accountFontImg,
      fileType: "2",
    },
    {
      filePath: merchant.accountBackImg,
      fileType: "3",
    },
    {
      filePath: settlement.accountCardImg,
      fileType: "1",
    },
  ];
  let id = data.storeMenAccount.id;

  data.storeMenAccount = {
    acconutArea3Text: settlement.acconutArea3Text,
    accountProvince: settlement.acconutArea3[0],
    accountCity: settlement.acconutArea3[1],
    accountDistrict: settlement.acconutArea3[2],
    accountIdcard: merchant.accountIdcard,
    accountIdcardExp: `${merchant.accountStartTime},${merchant.accountEndTime}`,
    accountUserName: merchant.accountUserName,
    bankAccountMobile: settlement.bankAccountMobile,
    bankCardNo: settlement.bankCardNo,
    bankId: settlement.bankId,
    bankIdText: settlement.bankIdText,
    bankIdHoText: settlement.bankIdHoText,
    bankIdHo: settlement.bankIdHo,
    accountStartTime: merchant.accountStartTime,
    accountEndTime: merchant.accountEndTime,
    storeMenId: storeMenId,
    id,
  };
  let arr = [];
  data.storeMenAuthList.forEach((item) => {
    if (item.storeMenAuth) {
      arr.push({
        storeMenAuth: item.storeMenAuth,
      });
    }
  });
  data.storeMenAuthList = arr;
  return put("/cloud-merchant/mrc/storemen/update", {
    ...data,
  });
};

// 提交未保存资料
export const save = (state) => {
  const { merchant, settlement } = state;
  const { userInfo } = state.user;
  var data;
  let storeAccountRates = [];

  if (merchant.openType == 2) {
    let storeAccountAttach = [];
    let arr = [
      //附件信息
      {
        //结算户身份证正面
        filePath: settlement.settleFontImg, //  结算法人不显示问题  merchant.legalFontImg ||
        fileType: "6",
      },
      {
        //结算户身份证反面
        filePath: settlement.settleBackImg, // 结算法人不显示问题 merchant.legalBackImg ||
        fileType: "7",
      },
      {
        //结算人手持身份证照
        filePath: settlement.settleHandFontImg || merchant.legalHandFontImg, // 对私对公的时候，法人和结算户的取的同一张
        fileType: "28",
      },
      {
        //营业执照
        filePath: merchant.bizImg,
        fileType: "3",
      },
      {
        //法人身份证正面
        filePath: merchant.legalFontImg, // 结算法人不显示问题 settlement.settleFontImg ||
        fileType: "1",
      },
      {
        //法人身份证反面
        filePath: merchant.legalBackImg, //  结算法人不显示问题   settlement.settleBackImg||
        fileType: "2",
      },
      {
        //法人手持身份证照
        filePath: merchant.legalHandFontImg,
        fileType: "8",
      },
      {
        //开户许可证
        filePath: settlement.openPermissionImg,
        fileType: "13",
      },
      {
        //营业场所照片
        filePath: merchant.storeAddressImg,
        fileType: "4",
      },
      {
        //门头照
        filePath: merchant.storeDoorImg,
        fileType: "12",
      },
      {
        //商户关系证明
        filePath: merchant.proofImg,
        fileType: "19",
      },
    ];
    var j = 14;
    for (var i = 0; i < merchant.assistImg.length; i++) {
      arr.push({
        filePath: merchant.assistImg[i].url,
        fileType: j,
      });
      j++;
    }
    arr.forEach((i) => {
      if (i.filePath) {
        storeAccountAttach.push(i);
      }
    });
    data = {
      id: userInfo.id,
      transactionType: merchant.payType,
      bizAddress: merchant.merchantAddress,
      bizProvince: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[0] : "",
      bizCity: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[1] : "",
      bizDistrict: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[2] : "",
      bizLicense: merchant.bizLicense,
      bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
      bizScope: merchant.bizScope,
      latitude: merchant.latitude,
      longitude: merchant.longitude,
      legalIdcard: merchant.legalIdcard,
      legalIdcardAddress: merchant.legalIdcardAddress,
      legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
      legalName: merchant.legalName,
      mcc: merchant.mcc,
      merchantId: userInfo.merchantId,
      storeFullName: merchant.merchantFullName,
      storeAbbrName: merchant.merchantAbbrName,
      storeAccountType: settlement.acconutType,
      storeAddress: merchant.merchantAddress,
      storeProvince: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[0] : "",
      storeCity: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[1] : "",
      storeDistrict: merchant.bizAreaId.length > 0 ? merchant.bizAreaId[2] : "",
      storeNature: merchant.openType,
      storeType: merchant.merchantType,
      storeMobile: userInfo.storeMobile,
      storeAccount: {},
      storeAccountAttach,
      storeAccountRates,
      // 推荐相关
      acquiringManager: merchant.acquiringManager,  // 联合收单推荐经理
      acquiringPeople: merchant.acquiringPeople,    // 联合收单推荐人
      acquiringRemarks: merchant.acquiringRemarks,  // 联合收单备注
    };
    console.log(storeAccountAttach, "storeAccountAttach--", merchant);
    if (
      (merchant.merchantType == 1 && settlement.acconutType == 1) ||
      (merchant.merchantType == 2 && settlement.acconutType == 1)
    ) {
      data.storeAccount = {
        accountCity:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[1] : "",
        accountDistrict:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[2] : "",
        accountName: merchant.merchantFullName,
        accountNo: settlement.accountNum1,
        checkApproveNo: settlement.checkApproveNo,
        accountProvince:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[0] : "",
        bankAccountMobile: settlement.accountMobile1,
        bankIdHo: settlement.bankId1,
        bankId: settlement.branchBankId1,

        accountIdcard: merchant.legalIdcard, //身份证号码
        accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //	身份证有效期
        accountImg: settlement.openPermissionImg, //开户许可证
        cardImg: "",
        idcard1Img: merchant.legalFontImg, //结算户身份证正面
        idcard2Img: merchant.legalBackImg, //结算户身份证反面
      };
    } else if (merchant.merchantType == 1 && settlement.acconutType == 2) {
      data.storeAccount = {
        accountCity:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[1] : "",
        accountDistrict:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[2] : "",
        accountName: settlement.accountName2,
        accountNo: settlement.accountNum2,
        accountProvince:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[0] : "",
        bankAccountMobile: settlement.accountMobile2,
        bankIdHo: settlement.bankId2,
        bankId: settlement.branchBankId2,

        accountIdcard: merchant.legalIdcard, //身份证号码
        accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //	身份证有效期
        accountImg: settlement.openPermissionImg,
        cardImg: settlement.bankCardImg, //银行卡正面
        card2Img: settlement.bankCard2Img, //银行卡反面
        idcard1Img: merchant.legalFontImg, //结算户身份证正面
        idcard2Img: merchant.legalBackImg, //结算户身份证反面

        companyAccountCity:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[1] : "",
        companyAccountDistrict:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[2] : "",
        companyAccountMobile: settlement.accountMobile1,
        companyAccountName: settlement.accountName1,
        companyAccountNo: settlement.accountNum1,
        checkApproveNo: settlement.checkApproveNo,
        companyAccountProvince:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[0] : "",
        companyBankId: settlement.branchBankId1, //支行
        companyBankIdHo: settlement.bankId1, //总行
      };
    } else if (merchant.merchantType == 1 && settlement.acconutType == 3) {
      console.log(settlement);
      data.storeAccount = {
        accountProvince:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[0] : "",
        accountCity:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[1] : "",
        accountDistrict:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[2] : "",
        accountName: settlement.accountName2,
        accountNo: settlement.accountNum2,
        bankAccountMobile: settlement.accountMobile2,
        bankIdHo: settlement.bankId2,
        bankId: settlement.branchBankId2,

        accountIdcard: settlement.settlementNum, //身份证号码
        accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`, //	身份证有效期
        accountImg: settlement.openPermissionImg,
        cardImg: settlement.bankCardImg, //银行卡正面
        card2Img: settlement.bankCard2Img, //银行卡反面
        idcard1Img: settlement.settleFontImg, //结算户身份证正面
        idcard2Img: settlement.settleBackImg, //结算户身份证反面
        idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照

        companyAccountCity:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[1] : "",
        companyAccountDistrict:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[2] : "",
        companyAccountMobile: settlement.accountMobile1,
        companyAccountName: settlement.accountName1,
        companyAccountNo: settlement.accountNum1,
        checkApproveNo: settlement.checkApproveNo,
        companyAccountProvince:
          settlement.acconutArea1.length > 0 ? settlement.acconutArea1[0] : "",
        companyBankId: settlement.branchBankId1, //支行
        companyBankIdHo: settlement.bankId1, //总行
      };
    } else if (merchant.merchantType == 2 && settlement.acconutType == 2) {
      data.storeAccount = {
        accountCity:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[1] : "",
        accountDistrict:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[2] : "",
        accountName: settlement.accountName2,
        accountNo: settlement.accountNum2,
        accountProvince:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[0] : "",
        bankAccountMobile: settlement.accountMobile2,
        bankIdHo: settlement.bankId2,
        bankId: settlement.branchBankId2,

        accountIdcard: merchant.legalIdcard, //身份证号码
        accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //身份证有效期
        accountImg: "",
        cardImg: settlement.bankCardImg, //银行卡正面
        card2Img: settlement.bankCard2Img, //银行卡反面
        idcard1Img: merchant.legalFontImg, //结算户身份证正面
        idcard2Img: merchant.legalBackImg, //结算户身份证反面
      };
    } else if (merchant.merchantType == 2 && settlement.acconutType == 3) {
      data.storeAccount = {
        accountProvince:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[0] : "",
        accountCity:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[1] : "",
        accountDistrict:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[2] : "",
        accountName: settlement.accountName2,
        accountNo: settlement.accountNum2,
        bankAccountMobile: settlement.accountMobile2,
        bankIdHo: settlement.bankId2,
        bankId: settlement.branchBankId2,

        accountIdcard: settlement.settlementNum, //身份证号码
        accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`, //身份证有效期
        accountImg: "",
        cardImg: settlement.bankCardImg, //银行卡正面
        card2Img: settlement.bankCard2Img, //银行卡反面
        idcard1Img: settlement.settleFontImg, //结算户身份证正面
        idcard2Img: settlement.settleBackImg, //结算户身份证反面
        idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照
      };
    } else if (merchant.merchantType == 3 && settlement.acconutType == 2) {
      data.storeAccount = {
        accountProvince:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[0] : "",
        accountCity:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[1] : "",
        accountDistrict:
          settlement.acconutArea2.length > 0 ? settlement.acconutArea2[2] : "",
        accountName: settlement.accountName2,
        accountNo: settlement.accountNum2,
        bankAccountMobile: settlement.accountMobile2,
        bankIdHo: settlement.bankId2,
        bankId: settlement.branchBankId2,

        accountIdcard: settlement.settlementNum,
        accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`,
        accountImg: "",
        cardImg: settlement.bankCardImg, //银行卡正面
        card2Img: settlement.bankCard2Img, //银行卡反面
        idcard1Img: settlement.settleFontImg, //结算户身份证正面
        idcard2Img: settlement.settleBackImg, //结算户身份证反面
        idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照
      };
      // 小薇 图片类型为 8 的图片兼容结算人手持
      data.storeAccountAttach.forEach((item) => {
        if (item.fileType === 8) {
          item.filePath = item.filePath || settlement.settleHandFontImg;
        }
      });
    }
  } else {
    let storeAccountAttach = [];
    let arr = [
      {
        //营业场所照片
        filePath: merchant.storeAddressImg,
        fileType: "4",
      },
      {
        //门头照
        filePath: merchant.storeDoorImg,
        fileType: "12",
      },
    ];
    var j = 14;
    for (var i = 0; i < merchant.assistImg.length; i++) {
      arr.push({
        filePath: merchant.assistImg[i].url,
        fileType: j,
      });
      j++;
    }
    arr.forEach((i) => {
      if (i.filePath) {
        storeAccountAttach.push(i);
      }
    });
    data = {
      id: userInfo.id,
      latitude: merchant.latitude,
      longitude: merchant.longitude,
      merchantId: userInfo.merchantId,
      storeFullName: merchant.merchantFullName,
      storeAbbrName: merchant.merchantAbbrName,
      storeAddress: merchant.merchantAddress,
      storeProvince: merchant.bizAreaId[0],
      storeCity: merchant.bizAreaId[1],
      storeDistrict: merchant.bizAreaId[2],
      storeNature: merchant.openType,
      storeMobile: userInfo.storeMobile,
      storeAccountAttach,
    };
  }
  console.log(merchant, "merchant--");

  if (merchant.cashierImg) {
    data.storeAccountAttach.push({
      filePath: merchant.cashierImg,
      fileType: "24",
    });
  }
  if (
    (merchant.merchantType === "1" || merchant.merchantType === "2") &&
    settlement.acconutType === "3" &&
    merchant.defaultChannelCode === "HAIKE"
  ) {
    data.storeAccountAttach.push({
      filePath: merchant.proofHandImg,
      fileType: "29",
    });
  }

  let arrList = [];
  data.storeAccountAttach.forEach((item) => {
    if (item.filePath) {
      arrList.push(item);
    }
  });
  data.storeAccountAttach = JSON.parse(JSON.stringify(arrList));
  // console.log(merchant.firstSettleType)
  // const [firstSettleType, entryChannelCode] = merchant.firstSettleType.split(
  //   "-"
  // );
  data.firstSettleType = merchant.firstSettleType;
  data.firstSettleTime = merchant.firstSettleTime;
  data.entryChannelId = merchant.entryChannelId;
  data.entryChannelCode = merchant.entryChannelCode;
  //保存未填完的资料
  data = removePropertyOfNull(data);
  data.isComplete = merchant.isComplete;
  console.log(data);
  if (userInfo.regStatus == 4 && userInfo.storeRegister.length > 0) {
    return post("/cloud-merchant/mrc/store/resubmit", {
      ...data,
    });
  } else {
    return post("/cloud-merchant/mrc/store/supplementary", {
      ...data,
    });
  }
};

// 补充资料
export const supplementary = (state) => {
  const { merchant, settlement } = state;
  const { userInfo } = state.user;
  var data;
  let storeAccountRates = [];
  if (merchant.openType == 2) {
    if (
      (merchant.merchantType == 1 && settlement.acconutType == 1) ||
      (merchant.merchantType == 2 && settlement.acconutType == 1)
    ) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        bizLicense: merchant.bizLicense,
        bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: merchant.legalIdcard,
        legalIdcardAddress: merchant.legalIdcardAddress,
        legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
        legalName: merchant.legalName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountCity: settlement.acconutArea1[1],
          accountDistrict: settlement.acconutArea1[2],
          accountName: merchant.merchantFullName,
          accountNo: settlement.accountNum1,
          checkApproveNo: settlement.checkApproveNo,
          accountProvince: settlement.acconutArea1[0],
          bankAccountMobile: settlement.accountMobile1,
          bankIdHo: settlement.bankId1,
          bankId: settlement.branchBankId1,

          accountIdcard: merchant.legalIdcard, //身份证号码
          accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //	身份证有效期
          accountImg: settlement.openPermissionImg, //开户许可证
          cardImg: "",
          idcard1Img: merchant.legalFontImg, //结算户身份证正面
          idcard2Img: merchant.legalBackImg, //结算户身份证反面
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //结算户身份证正面
            filePath: merchant.legalFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: merchant.legalBackImg,
            fileType: "7",
          },
          {
            //营业执照
            filePath: merchant.bizImg,
            fileType: "3",
          },
          {
            //法人身份证正面
            filePath: merchant.legalFontImg,
            fileType: "1",
          },
          {
            //法人身份证反面
            filePath: merchant.legalBackImg,
            fileType: "2",
          },
          {
            //法人手持身份证照
            filePath: merchant.legalHandFontImg,
            fileType: "8",
          },
          {
            //开户许可证
            filePath: settlement.openPermissionImg,
            fileType: "13",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
        ],
        storeAccountRates,
      };
    } else if (merchant.merchantType == 1 && settlement.acconutType == 2) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        bizLicense: merchant.bizLicense,
        bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: merchant.legalIdcard,
        legalIdcardAddress: merchant.legalIdcardAddress,
        legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
        legalName: merchant.legalName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountCity: settlement.acconutArea2[1],
          accountDistrict: settlement.acconutArea2[2],
          accountName: settlement.accountName2,
          accountNo: settlement.accountNum2,
          accountProvince: settlement.acconutArea2[0],
          bankAccountMobile: settlement.accountMobile2,
          bankIdHo: settlement.bankId2,
          bankId: settlement.branchBankId2,

          accountIdcard: merchant.legalIdcard, //身份证号码
          accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //	身份证有效期
          accountImg: settlement.openPermissionImg,
          cardImg: settlement.bankCardImg, //银行卡正面
          card2Img: settlement.bankCard2Img, //银行卡反面
          idcard1Img: merchant.legalFontImg, //结算户身份证正面
          idcard2Img: merchant.legalBackImg, //结算户身份证反面

          companyAccountCity: settlement.acconutArea1[1],
          companyAccountDistrict: settlement.acconutArea1[2],
          companyAccountMobile: settlement.accountMobile1,
          companyAccountName: settlement.accountName1,
          companyAccountNo: settlement.accountNum1,
          checkApproveNo: settlement.checkApproveNo,
          companyAccountProvince: settlement.acconutArea1[0],
          companyBankId: settlement.branchBankId1, //支行
          companyBankIdHo: settlement.bankId1, //总行
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //结算户身份证正面
            filePath: merchant.legalFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: merchant.legalBackImg,
            fileType: "7",
          },
          {
            //营业执照
            filePath: merchant.bizImg,
            fileType: "3",
          },
          {
            //法人身份证正面
            filePath: merchant.legalFontImg,
            fileType: "1",
          },
          {
            //法人身份证反面
            filePath: merchant.legalBackImg,
            fileType: "2",
          },
          {
            //结算人手持身份证照
            filePath: settlement.settleHandFontImg || merchant.legalHandFontImg, // 对私对公的时候，法人和结算户的取的同一张,
            fileType: "28",
          },
          {
            //法人手持身份证照
            filePath: merchant.legalHandFontImg,
            fileType: "8",
          },
          {
            //银行卡正面
            filePath: settlement.bankCardImg,
            fileType: "5",
          },
          {
            //银行卡反面
            filePath: settlement.bankCard2Img,
            fileType: "27",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
          {
            //开户许可证
            filePath: settlement.openPermissionImg,
            fileType: "13",
          },
        ],
        storeAccountRates,
      };
    } else if (merchant.merchantType == 1 && settlement.acconutType == 3) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        bizLicense: merchant.bizLicense,
        bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: merchant.legalIdcard,
        legalIdcardAddress: merchant.legalIdcardAddress,
        legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
        legalName: merchant.legalName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountProvince: settlement.acconutArea2[0],
          accountCity: settlement.acconutArea2[1],
          accountDistrict: settlement.acconutArea2[2],
          accountName: settlement.accountName2,
          accountNo: settlement.accountNum2,
          bankAccountMobile: settlement.accountMobile2,
          bankIdHo: settlement.bankId2,
          bankId: settlement.branchBankId2,

          accountIdcard: settlement.settlementNum, //身份证号码
          accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`, //	身份证有效期
          accountImg: settlement.openPermissionImg,
          cardImg: settlement.bankCardImg, //银行卡正面
          card2Img: settlement.bankCard2Img, //银行卡反面
          idcard1Img: settlement.settleFontImg, //结算户身份证正面
          idcard2Img: settlement.settleBackImg, //结算户身份证反面
          idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照

          companyAccountCity: settlement.acconutArea1[1],
          companyAccountDistrict: settlement.acconutArea1[2],
          companyAccountMobile: settlement.accountMobile1,
          companyAccountName: settlement.accountName1,
          companyAccountNo: settlement.accountNum1,
          checkApproveNo: settlement.checkApproveNo,
          companyAccountProvince: settlement.acconutArea1[0],
          companyBankId: settlement.branchBankId1, //支行
          companyBankIdHo: settlement.bankId1, //总行
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //营业执照
            filePath: merchant.bizImg,
            fileType: "3",
          },
          {
            //法人身份证正面
            filePath: merchant.legalFontImg,
            fileType: "1",
          },
          {
            //法人身份证反面
            filePath: merchant.legalBackImg,
            fileType: "2",
          },
          {
            //法人手持身份证照
            filePath: merchant.legalHandFontImg,
            fileType: "8",
          },
          {
            //银行卡正面
            filePath: settlement.bankCardImg,
            fileType: "5",
          },
          {
            //银行卡反面
            filePath: settlement.bankCard2Img,
            fileType: "27",
          },
          {
            //结算户身份证正面
            filePath: settlement.settleFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: settlement.settleBackImg,
            fileType: "7",
          },
          {
            //结算人手持身份证照
            filePath: settlement.settleHandFontImg,
            fileType: "28",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
          {
            //开户许可证
            filePath: settlement.openPermissionImg,
            fileType: "13",
          },
          {
            //商户关系证明
            filePath: merchant.proofImg,
            fileType: "19",
          },
        ],
        storeAccountRates,
      };
    } else if (merchant.merchantType == 2 && settlement.acconutType == 2) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        bizLicense: merchant.bizLicense,
        bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: merchant.legalIdcard,
        legalIdcardAddress: merchant.legalIdcardAddress,
        legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
        legalName: merchant.legalName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountCity: settlement.acconutArea2[1],
          accountDistrict: settlement.acconutArea2[2],
          accountName: settlement.accountName2,
          accountNo: settlement.accountNum2,
          accountProvince: settlement.acconutArea2[0],
          bankAccountMobile: settlement.accountMobile2,
          bankIdHo: settlement.bankId2,
          bankId: settlement.branchBankId2,

          accountIdcard: merchant.legalIdcard, //身份证号码
          accountIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`, //身份证有效期
          accountImg: "",
          cardImg: settlement.bankCardImg, //银行卡正面
          card2Img: settlement.bankCard2Img, //银行卡反面
          idcard1Img: merchant.legalFontImg, //结算户身份证正面
          idcard2Img: merchant.legalBackImg, //结算户身份证反面
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //结算户身份证正面
            filePath: merchant.legalFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: merchant.legalBackImg,
            fileType: "7",
          },
          {
            //营业执照
            filePath: merchant.bizImg,
            fileType: "3",
          },
          {
            //法人身份证正面
            filePath: merchant.legalFontImg,
            fileType: "1",
          },
          {
            //结算人手持身份证照
            filePath: settlement.settleHandFontImg || merchant.legalHandFontImg, // 对私对公的时候，法人和结算户的取的同一张,
            fileType: "28",
          },
          {
            //法人身份证反面
            filePath: merchant.legalBackImg,
            fileType: "2",
          },
          {
            //法人手持身份证照
            filePath: merchant.legalHandFontImg,
            fileType: "8",
          },
          {
            //银行卡正面
            filePath: settlement.bankCardImg,
            fileType: "5",
          },
          {
            //银行卡反面
            filePath: settlement.bankCard2Img,
            fileType: "27",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
        ],
        storeAccountRates,
      };
    } else if (merchant.merchantType == 2 && settlement.acconutType == 3) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        bizLicense: merchant.bizLicense,
        bizLicenseExp: `${merchant.bizStartTime},${merchant.bizEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: merchant.legalIdcard,
        legalIdcardAddress: merchant.legalIdcardAddress,
        legalIdcardExp: `${merchant.legalStartTime},${merchant.legalEndTime}`,
        legalName: merchant.legalName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountProvince: settlement.acconutArea2[0],
          accountCity: settlement.acconutArea2[1],
          accountDistrict: settlement.acconutArea2[2],
          accountName: settlement.accountName2,
          accountNo: settlement.accountNum2,
          bankAccountMobile: settlement.accountMobile2,
          bankIdHo: settlement.bankId2,
          bankId: settlement.branchBankId2,

          accountIdcard: settlement.settlementNum, //身份证号码
          accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`, //身份证有效期
          accountImg: "",
          cardImg: settlement.bankCardImg, //银行卡正面
          card2Img: settlement.bankCard2Img, //银行卡反面
          idcard1Img: settlement.settleFontImg, //结算户身份证正面
          idcard2Img: settlement.settleBackImg, //结算户身份证反面
          idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //营业执照
            filePath: merchant.bizImg,
            fileType: "3",
          },
          {
            //法人身份证正面
            filePath: merchant.legalFontImg,
            fileType: "1",
          },
          {
            //法人身份证反面
            filePath: merchant.legalBackImg,
            fileType: "2",
          },
          {
            //法人手持身份证照
            filePath: merchant.legalHandFontImg,
            fileType: "8",
          },
          {
            //银行卡正面
            filePath: settlement.bankCardImg,
            fileType: "5",
          },
          {
            //银行卡反面
            filePath: settlement.bankCard2Img,
            fileType: "27",
          },
          {
            //结算户身份证正面
            filePath: settlement.settleFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: settlement.settleBackImg,
            fileType: "7",
          },
          {
            //结算人手持身份证照
            filePath: settlement.settleHandFontImg,
            fileType: "28",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
          {
            //商户关系证明
            filePath: merchant.proofImg,
            fileType: "19",
          },
        ],
        storeAccountRates,
      };
    } else if (merchant.merchantType == 3 && settlement.acconutType == 2) {
      data = {
        id: userInfo.id,
        transactionType: merchant.payType,
        bizAddress: merchant.merchantAddress,
        bizProvince: merchant.bizAreaId[0],
        bizCity: merchant.bizAreaId[1],
        bizDistrict: merchant.bizAreaId[2],
        // bizLicense: merchant.bizLicense,
        // bizLicenseExp: `${settlement.idCardStartTime},${
        //     settlement.idCardEndTime}`,
        bizScope: merchant.bizScope,
        latitude: merchant.latitude,
        longitude: merchant.longitude,
        legalIdcard: settlement.settlementNum,
        legalIdcardAddress: settlement.legalIdcardAddress,
        legalIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`,
        legalName: settlement.settlementName,
        mcc: merchant.mcc,
        merchantId: userInfo.merchantId,
        storeFullName: merchant.merchantFullName,
        storeAbbrName: merchant.merchantAbbrName,
        storeAccountType: settlement.acconutType,
        storeAddress: merchant.merchantAddress,
        storeProvince: merchant.bizAreaId[0],
        storeCity: merchant.bizAreaId[1],
        storeDistrict: merchant.bizAreaId[2],
        storeNature: merchant.openType,
        storeType: merchant.merchantType,
        storeMobile: userInfo.storeMobile,
        storeAccount: {
          accountProvince: settlement.acconutArea2[0],
          accountCity: settlement.acconutArea2[1],
          accountDistrict: settlement.acconutArea2[2],
          accountName: settlement.accountName2,
          accountNo: settlement.accountNum2,
          bankAccountMobile: settlement.accountMobile2,
          bankIdHo: settlement.bankId2,
          bankId: settlement.branchBankId2,

          accountIdcard: settlement.settlementNum,
          accountIdcardExp: `${settlement.idCardStartTime},${settlement.idCardEndTime}`,
          accountImg: "",
          cardImg: settlement.bankCardImg, //银行卡正面
          card2Img: settlement.bankCard2Img, //银行卡反面
          idcard1Img: settlement.settleFontImg, //结算户身份证正面
          idcard2Img: settlement.settleBackImg, //结算户身份证反面
          idcard3Img: settlement.settleHandFontImg, //结算人手持身份证照
        },
        storeAccountAttach: [
          //附件信息
          {
            //电子签名
            filePath: merchant.signature,
            fileType: "22",
          },
          {
            //银行卡正面
            filePath: settlement.bankCardImg,
            fileType: "5",
          },
          {
            //银行卡反面
            filePath: settlement.bankCard2Img,
            fileType: "27",
          },
          {
            //法人
            filePath: settlement.settleFontImg,
            fileType: "1",
          },
          {
            //法人
            filePath: settlement.settleBackImg,
            fileType: "2",
          },
          {
            //结算户身份证正面
            filePath: settlement.settleFontImg,
            fileType: "6",
          },
          {
            //结算户身份证反面
            filePath: settlement.settleBackImg,
            fileType: "7",
          },
          {
            //结算人手持身份证照
            filePath: settlement.settleHandFontImg || merchant.legalHandFontImg, // 对私对公的时候，法人和结算户的取的同一张,
            fileType: "28",
          },
          {
            //法人手持身份证照 小微的法人手持身份证照 = 结算户手持身份证照
            filePath: settlement.legalHandFontImg || merchant.settleHandFontImg,
            fileType: "8",
          },
          {
            //营业场所照片
            filePath: merchant.storeAddressImg,
            fileType: "4",
          },
          {
            //门头照
            filePath: merchant.storeDoorImg,
            fileType: "12",
          },
        ],
        storeAccountRates,
      };
    }
  } else {
    data = {
      id: userInfo.id,
      latitude: merchant.latitude,
      longitude: merchant.longitude,
      merchantId: userInfo.merchantId,
      storeFullName: merchant.merchantFullName,
      storeAbbrName: merchant.merchantAbbrName,
      storeAddress: merchant.merchantAddress,
      storeProvince: merchant.bizAreaId[0],
      storeCity: merchant.bizAreaId[1],
      storeDistrict: merchant.bizAreaId[2],
      storeNature: merchant.openType,
      storeMobile: userInfo.storeMobile,
      storeAccountAttach: [
        //附件信息
        {
          //电子签名
          filePath: merchant.signature,
          fileType: "22",
        },
        {
          //营业场所照片
          filePath: merchant.storeAddressImg,
          fileType: "4",
        },
        {
          //门头照
          filePath: merchant.storeDoorImg,
          fileType: "12",
        },
      ],
    };
  }
  var j = 14;
  for (var i = 0; i < merchant.assistImg.length; i++) {
    if (merchant.assistImg[i].url) {
      data.storeAccountAttach.push({
        filePath: merchant.assistImg[i].url,
        fileType: j,
      });
    }
    j++;
  }
  // if(merchant.payType === '2' || merchant.payType === 2){
  //   data.storeAccountAttach.push({
  //     filePath: merchant.cashierImg,
  //     fileType: "24"
  //   });
  // }
  if (merchant.cashierImg) {
    data.storeAccountAttach.push({
      filePath: merchant.cashierImg,
      fileType: "24",
    });
  }
  if (
    (merchant.merchantType === "1" || merchant.merchantType === "2") &&
    settlement.acconutType === "3" &&
    merchant.defaultChannelCode === "HAIKE"
  ) {
    data.storeAccountAttach.push({
      filePath: merchant.proofHandImg,
      fileType: "29",
    });
  }
  let arrList = [];
  data.storeAccountAttach.forEach((item) => {
    if (item.filePath) {
      arrList.push(item);
    }
  });
  data.storeAccountAttach = JSON.parse(JSON.stringify(arrList));
  // const [
  //   entryChannelId,
  //   firstSettleType,
  //   entryChannelCode,
  // ] = merchant.firstSettleType.split(",");
  // data.firstSettleType = firstSettleType;
  // data.entryChannelId = entryChannelId;
  // data.entryChannelCode = entryChannelCode;

  data.firstSettleType = merchant.firstSettleType;
  data.firstSettleTime = merchant.firstSettleTime;
  data.entryChannelId = merchant.entryChannelId;
  data.entryChannelCode = merchant.entryChannelCode;
  data.acquiringManager= merchant.acquiringManager  // 联合收单推荐经理
  data.acquiringPeople= merchant.acquiringPeople    // 联合收单推荐人
  data.acquiringRemarks= merchant.acquiringRemarks  // 联合收单备注
  if (data.storeAccountRates && data.storeAccountRates.length > 0) {
    // 临时处理
    data.storeAccountRates.map((item) => {
      item.rateValue = item.rateValue || 0;
      return item;
    });
  }
  data.isComplete = merchant.isComplete;
  //重新进件
  if (userInfo.regStatus == 4 && userInfo.storeRegister.length > 0) {
    return post("/cloud-merchant/mrc/store/resubmit", {
      ...data,
    });
  } else {
    return post("/cloud-merchant/mrc/store/supplementary", {
      ...data,
    });
  }
};
// 查询配置接口
export const queryRegisterConfig = (params) => {
  return get("/cloud-merchant/mrc/registerConfig/query", params);
};
